//
//  CAQRCodeView.m
//  LNH
//
//  Created by twentylx on 2018/1/23.
//  Copyright © 2018年 twentylx. All rights reserved.
//

#import "CAQRCodeView.h"

@implementation CAQRCodeView

/**
 为视图绑定 viewModel
 
 @param viewModel 要绑定的ViewModel
 @param params 额外参数
 */
- (void)bindViewModel:(id <LMViewProtocol>)viewModel withParams:(NSDictionary *)params {
    
}


/**
 初始化额外数据
 */
- (void)lm_initializeForView {
    
}

/**
 初始化视图
 */
- (void)lm_createViewForView{
    [self setNeedsUpdateConstraints];
    
    [self addSubview:self.logoImageView];
    [self addSubview:self.titleLabel];
    [self addSubview:self.descriptionLabel];
    [self addSubview:self.nameLabel];
    [self addSubview:self.noLabel];
    [self addSubview:self.qrCodeImageView];
}

#pragma mark layout
- (void)updateConstraints {
    [super updateConstraints];
    
    [_logoImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self).offset(40);
        make.top.equalTo(self).offset(40);
        make.width.mas_equalTo(80);
        make.height.mas_equalTo(80);
    }];
    
    [_titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.logoImageView.mas_right).offset(20);
        make.top.equalTo(self.logoImageView).offset(5);
    }];
    
    [_descriptionLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.titleLabel);
        make.top.equalTo(self.titleLabel.mas_bottom).offset(5);
    }];
    
    [_nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.logoImageView.mas_right).offset(30);
        make.top.equalTo(self.descriptionLabel.mas_bottom).offset(15);
    }];
    
    [_noLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.logoImageView.mas_right);
        make.top.equalTo(self.nameLabel.mas_bottom).offset(10);
    }];
    
    [_qrCodeImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self);
        make.top.equalTo(self.noLabel.mas_bottom).offset(20);
        make.width.mas_equalTo(250);
        make.height.mas_equalTo(250);
    }];
}

#pragma mark get & set
- (UIImageView *)logoImageView {
    if (!_logoImageView) {
        _logoImageView = [UIImageView new];
        _logoImageView.image = LMImageNamed(@"qrcode_logo");
        _logoImageView.layer.cornerRadius = 15;
    }
    return _logoImageView;
}

- (UILabel *)titleLabel {
    if (!_titleLabel) {
        _titleLabel = [UILabel new];
        _titleLabel.text = @"靓女汇商城";
        _titleLabel.font = [UIFont systemFontOfSize:16];
        _titleLabel.textColor = RGBCOLOR(77, 77, 77);
    }
    return _titleLabel;
}

- (UILabel *)descriptionLabel {
    if (!_descriptionLabel) {
        _descriptionLabel = [UILabel new];
        _descriptionLabel.text = @"每个人都能买的奢侈品";
        _descriptionLabel.font = [UIFont systemFontOfSize:12];
        _descriptionLabel.textColor = RGBCOLOR(77, 77, 77);
    }
    return _descriptionLabel;
}

- (UILabel *)nameLabel {
    if (!_nameLabel) {
        _nameLabel = [UILabel new];
//        _nameLabel.text = @"张三";
        _nameLabel.font = [UIFont systemFontOfSize:16];
        _nameLabel.textColor = RGBCOLOR(77, 77, 77);
    }
    return _nameLabel;
}

- (UILabel *)noLabel {
    if (!_noLabel) {
        _noLabel = [UILabel new];
//        _noLabel.text = @"(推荐码：88888)";
        _noLabel.font = [UIFont systemFontOfSize:14];
        _noLabel.textColor = RGBCOLOR(77, 77, 77);
    }
    return _noLabel;
}

- (UIImageView *)qrCodeImageView {
    if (!_qrCodeImageView) {
        _qrCodeImageView = [UIImageView new];
//        _qrCodeImageView.image = LMImageNamed(@"category");
    }
    return _qrCodeImageView;
}


@end
